<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <#include "../common/header.ftl">
    <script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
</head>
<script>
    $(function () {
        $('#pagination').twbsPagination({
            totalPages:${result.pages},
            startPage:${result.pageNum},
            visiblePages:${result.pageSize},
            first:"首页",
            prev:"上一页",
            next:"下一页",
            last:"莫邪",

            onPageClick:function(event,page){
                $('#currentPage').val(page);
                $("#searchForm").submit();
            }
        });



        $(".editBtn").click(function () {
            var data = $(this).data("jsonstr")
            $("#customerTraceHistorytId").val(data.id)
            $("#history_customerId").val(data.customerId)
            $("#customerName").val(data.customerName)
            $("#traceTime").val(data.traceTime)
            $("#traceDetails").val(data.traceDetails)
            $("#traceType").val(data.traceTypeId)
            $("#traceResult").val(data.traceResult)
            $("#remark").val(data.remark)
            $("#type").val(data.type)
            $("#customerTraceHistoryModel").modal('show')
        })
        
        $(".saveBtn").click(function () {
           $("#customerTraceHistoryeDitForm").ajaxSubmit(function (data) {
               showMessager(data);
           })
        })


       

    })



    
</script>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">客户跟进历史管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/customerTraceHistory/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}" placeholder="请输入姓名/电话">
                </div>
                <div class="form-group">
                    <label for="type">状态:</label>
                    <select class="form-control" id="type" name="type">
                        <option value="-1">全部</option>
                        <option value="0">潜在客户开发</option>
                        <option value="1">正式客户跟进</option>
                    </select>
                    <script>
                        $("#status option[value='${qo.type}']").prop("selected", true);
                    </script>
                </div>
                <button id="btn_query" class="btn btn-default">查询</button>

            </form>

            <table class="table table-striped table-hover" >
                <thead>
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                        <th>跟进日期</th>
                        <th>跟进内容</th>
                        <th>跟进方式</th>
                        <th>跟进结果</th>
                        <th>录入人</th>
                        <th>跟进类型</th>
                        <th>操作</th>
                    </tr>
                </thead>
                   <#list result.list as entity>
                   <tr>
                       <td>${entity_index+1}</td>
                       <td>${(entity.customer.name)!}</td>
                       <td>${entity.traceTime?string("yyyy-MM-dd")}</td>
                       <td>${(entity.traceDetails)!}</td>
                       <td>${(entity.traceType.title)!}</td>
                       <td>
                        <#if entity.traceResult==1>
                            差
                            <#elseif entity.traceResult==2>
                            中
                            <#elseif entity.traceResult==3>
                            优
                        </#if>
                       </td>


                       <td>${(entity.inputUser.name)!}</td>


                       <td><#if (entity.type)! == 0>
                           潜在客户开发
                            <#elseif (entity.type)! == 1>
                                正式客户跟进
                       </#if></td>
                       <td>

                               <a class="btn btn-info btn-xs editBtn " data-jsonstr='${(entity.jsonString)!}'>
                                   <span class="glyphicon glyphicon-pencil "></span>编辑
                               </a>

                       </td>
                   </tr>
               </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>

<div class="modal fade " tabindex="-1" id="customerTraceHistoryModel" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">客户编辑/保存</h4>
            </div>
                <div class="modal-body">
                    <form class="form-horizontal" action="/customerTraceHistory/saveOrUpdate.do" method="post" id="customerTraceHistoryeDitForm">
                        <input type="hidden" id="customerTraceHistorytId" name="id">
                        <div class="form-group" >
                            <label for="name" class="col-sm-3 control-label">客户名称：</label>
                            <div class="col-sm-6">
                                <input type="hidden" class="form-control" id="history_customerId" name="customer.id" >
                                <input type="text" class="form-control" id="customerName" readonly >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="age" class="col-sm-3 control-label">跟进时间：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" id="traceTime" name="traceTime" onclick="WdatePicker()">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="qq" class="col-sm-3 control-label">跟进内容：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" id="traceDetails" name="traceDetails" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="job" class="col-sm-3 control-label">跟进方式：</label>
                            <div class="col-sm-6">
                                <select name="traceType.id" class="form-control" id="traceType">
                                <#list (traceTypes)! as t>
                                    <option class="form-control"  value="${t.id}">${t.title}</option>
                                </#list>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="gender" class="col-sm-3 control-label">跟进结果：</label>
                            <div class="col-sm-6">
                                <select name="traceResult" id="traceResult" class="form-control">
                                    <option class="form-control" value="1">差</option>
                                    <option class="form-control" value="2">中</option>
                                    <option class="form-control" value="33">优</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="tel" class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" id="remark" name="remark" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="gender" class="col-sm-3 control-label">跟进类型：</label>
                            <div class="col-sm-6">
                                <select name="type" id="type" class="form-control">
                                    <option class="form-control" value="0">潜在客户开发</option>
                                    <option class="form-control" value="1">正式客户跟进</option>
                                </select>
                            </div>
                        </div>
                    </form>
                </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary saveBtn" >确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


</body>
</html>